package com.xingyi.bacs.controller;

import com.xingyi.bacs.bean.Bill;
import com.xingyi.bacs.bean.Merchant;
import com.xingyi.bacs.bean.Settlement;
import com.xingyi.bacs.service.QsService;
import com.xingyi.bacs.vo.ResponeBodyVo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by wujt on 8/10/2021
 */
@RestController
@RequestMapping("/qs")
public class QsController {

    @Resource
    private QsService qsService;

    @RequestMapping("/merchant")
    public ResponeBodyVo getMerchant(String date){
        ResponeBodyVo responeBodyVo = new ResponeBodyVo();
        List<Merchant> list = qsService.runMerchant(date);
        responeBodyVo.setData(list);
        responeBodyVo.setErrorCode(ResponeBodyVo.SUCCESS);
        return responeBodyVo;
    }

    @RequestMapping("/settlement")
    public ResponeBodyVo getSettlement(String date){
        ResponeBodyVo responeBodyVo = new ResponeBodyVo();
        qsService.deleteSettlement(date);
        List<Settlement> list = qsService.runSettlement(date);
        responeBodyVo.setData(list);
        responeBodyVo.setErrorCode(ResponeBodyVo.SUCCESS);
        return responeBodyVo;
    }

    @RequestMapping("/bill")
    public ResponeBodyVo getBill(){
        ResponeBodyVo responeBodyVo = new ResponeBodyVo();
        List<Bill> list = qsService.runBill();
        responeBodyVo.setData(list);
        responeBodyVo.setErrorCode(ResponeBodyVo.SUCCESS);
        return responeBodyVo;
    }
}
